package com.gaotu.demo.mybatis;

import com.gaotu.demo.User;
import com.gaotu.demo.UserDao;
import com.gaotu.demo.mybatis.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class MapperProxyBasedUserDao implements UserDao {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void insert(User user) {
        this.userMapper.insert(user);
    }

    @Override
    public void update(User user) {
        this.userMapper.updateByPrimaryKey(user);
    }

    @Override
    public void deleteById(Long id) {
        this.userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public User getById(Long id) {
        return this.userMapper.selectByPrimaryKey(id);
    }


    @Override
    public User getByName(String name) {
        return this.userMapper.selectByName(name);
    }

}
